from django.db import models

from TestInterface.models import TestInterfaceModel


# Create your models here.


class BugManage(models.Model):
    """
    | 字段          | 类型         | 空   | 默认  | 注释      |
    |:----------- |:---------- |:--- | --- | ------- |
    | id          | int        | 否   |     | 自增长主键ID |
    | interface   | ForeignKey | 否   |     | 接口      |
    | create_time | datatime   | 否   |     | 提交时间    |
    | desc        | varchar    | 是   |     | bug描述   |
    | info        | Json       | 是   |     | bug详细信息 |
    | status      | varchar    | 否   |     | bug状态   |
    | user        | varchar    | 是   |     | 提交者     |
    """
    interface = models.ForeignKey(TestInterfaceModel, on_delete=models.CASCADE, verbose_name="接口", help_text="接口")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="提交时间", help_text="提交时间")
    desc = models.CharField(max_length=150, verbose_name="bug描述", help_text="bug描述", blank=True,
                            default="")
    info = models.JSONField(verbose_name="bug详情信息", help_text="bug详情描述", blank=True, default=dict)
    status = models.CharField(max_length=50, verbose_name="bug状态", help_text="bug状态")
    user = models.CharField(max_length=20, verbose_name="提交者", help_text="提交者", blank=True)

    class Meta:
        db_table = "bug_manage"
        verbose_name_plural = "bug管理表"


class BugHandle(models.Model):
    """
    | 字段          | 类型         | 空   | 默认  | 注释      |
    |:----------- |:---------- |:--- | --- | ------- |
    | id          | int        | 否   |     | 自增长主键ID |
    | bug         | ForeignKey | 否   |     | bug     |
    | create_time | datatime   | 否   |     | 提交时间    |
    | handle      | TextField  | 是   |     | 处理操作    |
    | update_user | varchar    | 是   |     | 处理用户    |

    """
    bug = models.ForeignKey(BugManage, on_delete=models.CASCADE, verbose_name="bug", help_text="bug")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="操作时间",
                                       help_text="操作时间")
    handle = models.TextField(verbose_name="处理操作", help_text="处理操作", blank=True)
    update_user = models.CharField(max_length=10, verbose_name="处理用户", help_text="处理用户", blank=True)

    class Meta:
        db_table = "bug_handle"
        verbose_name_plural = "bug处理记录表"
